package com.htsk.city.services.core.dao;

import cn.hutool.json.JSONObject;
import com.htsk.city.services.core.domain.ServiceCategory;
import com.htsk.city.services.core.domain.ServiceSubCategory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

public interface ServiceSubCategoryDao extends JpaRepository<ServiceSubCategory, Long> {

    @Query(value = "select cs.id,sc.service_category_id as serviceCategoryId,sc.id as serviceSubCategoryId,sc.service_sub_category_name as serviceSubCategoryName," +
            "cs.introduce_image as introduceImage from city_service_sub_category cs left join service_sub_category sc on cs.service_sub_category_id=sc.id where cs.city_id=?1 and " +
            " sc.service_category_id=?2 and sc.del_flag=0 and sc.status=1 order by sc.id desc ",nativeQuery = true)
    List<Map<String,Object>> queryByCityId(Long cityId, Long serviceCategoryId);

    @Query(value = "select cs.id,sc.service_category_id as serviceCategoryId,sc.id as serviceSubCategoryId,sc.service_sub_category_name as serviceSubCategoryName," +
            "cs.introduce_image as introduceImage from city_service_sub_category cs left join service_sub_category sc on cs.service_sub_category_id=sc.id where cs.city_id=?1 and " +
            " sc.del_flag=0 and sc.status=1 order by sc.id desc ",nativeQuery = true)
    List<Map<String,Object>> queryByCityId(Long cityId);

}
